package com.pfzy.utildemo.activity.load;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.amap.api.maps.MapsInitializer;
import com.pfzy.utildemo.MainActivity;
import com.pfzy.utildemo.R;
import com.pfzy.utildemo.activity.base.BaseActivity;
import com.pfzy.utildemo.activity.load.protocol.PrivacyProtocolAgreedListener;
import com.pfzy.utildemo.activity.load.protocol.PrivacyProtocolManager;
import com.pfzy.lib.config.AppConfig;

public class LoadActivity extends BaseActivity implements View.OnClickListener {
    private ImageView mAd;
    private TextView mJump;
    private View mLogo;
    private View mAdClickView;
    private TextView mAdClickText;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        disableDefaultImmersBar();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_load);
        initView();
    }

    private void initView() {
        this.mAd = (ImageView) findViewById(R.id.load_riv_ad);
        this.mJump = (TextView) findViewById(R.id.load_tv_jump);
        this.mLogo = findViewById(R.id.load_ll_logo);
        this.mAdClickView = findViewById(R.id.load_layout_ad_click);
        this.mAdClickText = (TextView) findViewById(R.id.load_tv_ad_click);
        this.mLogo.setOnClickListener(this);

        // 是否同意隐私协议
        if (AppConfig.isPrivacyProtocolAgreed()) {
            initAfterAgreeProtocol();
        } else {
            MapsInitializer.updatePrivacyShow(this, true, true);
            FrameLayout layout = findViewById(R.id.fl_privacy_protocol);
            PrivacyProtocolManager.getInstance().showPrivacyDialog(this, layout, new PrivacyProtocolAgreedListener() {
                @Override
                public void agreed() {
                    initAfterAgreeProtocol();
                }
            });
        }
    }

    @Override
    public void onClick(View view) {
    }

    /**
     * 同意协议后初始化
     */
    public void initAfterAgreeProtocol() {
        MapsInitializer.updatePrivacyAgree(this, true);

        Intent intent = new Intent();
        intent.setClass(this, MainActivity.class);
        startActivity(intent);
    }
}
